'''
获取百度百科（周杰伦）里面词条详细内容
'''
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re

html = urlopen("https://baike.baidu.com/item/%E5%91%A8%E6%9D%B0%E4%BC%A6/129156")
bsObj = BeautifulSoup(html, "html.parser")

content = bsObj.find("dl", {"id": "posterCon"}).findAll("a", href = re.compile("^(/item/).*\/[0-9]*"))
# print(content)
for x in content:
    print(x.attrs["href"])
    print(x.get_text())